package com.ziguang.redwood.admin.controller;

import java.io.File;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jfinal.core.Controller;
import com.jfinal.ext.route.ControllerBind;
import com.ziguang.common.SysConstant;

@ControllerBind(controllerKey = "/down", viewPath = "/admin")
public class DownloadController extends Controller{
	
	private static final Logger log  = LoggerFactory.getLogger(DownloadController.class);
	
	/**
	 * 图片下载
	 */
	public void downHomeImg(){
		String imgUrl = this.getPara("imgUrl");
		String img = SysConstant.UPLOAD_ROOT_PATH+"home"+File.separator+imgUrl;
		log.info("==="+img);
		File file = new File(img);
		renderFile(file);
	}
	
	/**
	 * 产品图片下载
	 */
	public void downProductImg(){
		String imgUrl = this.getPara("imgUrl");
		String img = SysConstant.UPLOAD_ROOT_PATH+"product"+File.separator+imgUrl;
		log.info("==="+img);
		File file = new File(img);
		renderFile(file);
	}
	
	/**
	 * 产品分类图片下载
	 */
	public void downProductTypeImg(){
		String imgUrl = this.getPara("imgUrl");
		String img = SysConstant.UPLOAD_ROOT_PATH+"productType"+File.separator+imgUrl;
		log.info("==="+img);
		File file = new File(img);
		renderFile(file);
	}
	
	/**
	 * 新闻动态图片下载
	 */
	public void downNewsImg(){
		String imgUrl = this.getPara("imgUrl");
		String img = SysConstant.UPLOAD_ROOT_PATH+"news"+File.separator+imgUrl;
		log.info("==="+img);
		File file = new File(img);
		renderFile(file);
	}

}
